package NWish.properties.object3ds
{
	import NWish.Interface.ILogger;
	import NWish.properties.FileProperties;
	
	import away3d.entities.Mesh;

	public class MeshLoaderProperties extends MeshProperties
	{
		private var _meshFilePor;
		static public const extraFileName = 'meshFileName';
		
		public function MeshLoaderProperties(app)
		{
			super(app);

			addPropertieKeys('mesh files'
				,[new FileProperties(app, extraFileName, ['.md5mesh','.obj','.3ds','.ac3d','.awd','.md2'])]);
		}
		
		override public function get type()
		{
			return Mesh;
		}
		
		override public function get createEnable()
		{
			return true;
		}
		
		override public function toString()
		{
			return "Mesh";
		}
		
		override public function get multiCreateEnable()
		{
			return true;
		}
		
		//
		override public function newType(scene,dict)
		{
			if(dict == null)
				return new Mesh();
			
			if(scene)
			{
				var file = dict['file'];
				
				if(file == '' || file == null)
				{
					ILogger.log('please select a mesh file!');
					return;
				}
				
				//
				var geometry = fileSystem.getResource(file);
				
				if(geometry)
				{
					var c = new Mesh(null,geometry);
					c.extra = new Object();
					c.extra[extraFileName] = file;
					return c;
				}
			}
			
			return null;
		}
	}
}


